<?xml version="1.0" encoding="UTF-8"?>
<!--
    MusicPliz
-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets">
<h:head>
	<title>MusicPliz</title>
	<script type="text/javascript">
		function confirmDelete(){
			if (!confirm('Suprimmer ce message ?'))
				return false;
			else
				return true;
		}
	</script>
        

</h:head>
<h:body>
	<h:outputStylesheet name="style.css" library="css" />
	<ui:include src="/WEB-INF/includes/header.xhtml" />
	<div id="container">
	<h:messages showDetail="false" showSummary="true" infoClass="info" errorClass="error"/>
	<h1>
		<h:outputText value="Messages réçus : #{MessagesBean.getReceivedCount()}" />
	</h1>
	<h2>	
		<h:outputText value="Messages non-lus : #{MessagesBean.getNewReceivedCount()}" />
	</h2>
	<h:form id="receivedForm">
		<h:dataTable var="message" value="#{MessagesBean.receivedMessages}" binding="#{MessagesBean.dataTable}">
				<h:column>
					<f:facet name="header">
					</f:facet>
					<h:graphicImage library="images" name="msg_unread.png" alt="non-lu" rendered="#{message.isUnread()}"/>
					<h:graphicImage library="images" name="msg_read.png" alt="lu" rendered="#{message.isRead()}"/>
					<h:graphicImage library="images" name="msg_replied.png" alt="répondu" rendered="#{message.isReplied()}"/>
				</h:column>
				<h:column>
					<f:facet name="header">
						<h:outputText value="expéditeur" />
					</f:facet>
					<h:outputText value="#{message.expediteur.prenom} #{message.expediteur.nom}" />
				</h:column>
				<h:column>
					<f:facet name="header">
						<h:outputText value="objet" />
					</f:facet>
					<h:commandLink action="#{MessagesBean.viewMessage}">
						<h:outputText value="#{message.objet}" />
					</h:commandLink>
				</h:column>
				<h:column>
					<f:facet name="header">
						<h:outputText value="date" />
					</f:facet>
					<h:outputText value="#{message.dateCreation}" />
				</h:column>
				<h:column>
					<f:facet name="header">
						<h:outputText value="supprimer" />
					</f:facet>
					<h:commandButton value="supprimer" onclick="return confirmDelete();" action="#{MessagesBean.delete}" />  
				</h:column>
		</h:dataTable>
	</h:form>
	<div class="navigationLinks">
		<h:link outcome="#{NavigationBean.getSentSite()}" value="messages envoyés" />
		<h:link outcome="#{NavigationBean.getHomeSite()}" value="retour au Home" />
	</div>
	</div>
</h:body>
</html>
